package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsStreamPlatform;
import com.scau402.system.service.IWmsStreamPlatformService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 直播平台Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/streamPlatform")
public class WmsStreamPlatformController extends BaseController
{
    @Autowired
    private IWmsStreamPlatformService wmsStreamPlatformService;

    /**
     * 查询直播平台列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamPlatform:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsStreamPlatform wmsStreamPlatform)
    {
        startPage();
        List<WmsStreamPlatform> list = wmsStreamPlatformService.selectWmsStreamPlatformList(wmsStreamPlatform);
        return getDataTable(list);
    }

    /**
     * 导出直播平台列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamPlatform:export')")
    @Log(title = "直播平台", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsStreamPlatform wmsStreamPlatform)
    {
        List<WmsStreamPlatform> list = wmsStreamPlatformService.selectWmsStreamPlatformList(wmsStreamPlatform);
        ExcelUtil<WmsStreamPlatform> util = new ExcelUtil<WmsStreamPlatform>(WmsStreamPlatform.class);
        util.exportExcel(response, list, "直播平台数据");
    }

    /**
     * 获取直播平台详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:streamPlatform:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsStreamPlatformService.selectWmsStreamPlatformById(id));
    }

    /**
     * 新增直播平台
     */
    @PreAuthorize("@ss.hasPermi('system:streamPlatform:add')")
    @Log(title = "直播平台", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsStreamPlatform wmsStreamPlatform)
    {
        wmsStreamPlatform.setCreateBy(getUsername());
        return toAjax(wmsStreamPlatformService.insertWmsStreamPlatform(wmsStreamPlatform));
    }

    /**
     * 修改直播平台
     */
    @PreAuthorize("@ss.hasPermi('system:streamPlatform:edit')")
    @Log(title = "直播平台", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsStreamPlatform wmsStreamPlatform)
    {
        return toAjax(wmsStreamPlatformService.updateWmsStreamPlatform(wmsStreamPlatform));
    }

    /**
     * 删除直播平台
     */
    @PreAuthorize("@ss.hasPermi('system:streamPlatform:remove')")
    @Log(title = "直播平台", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsStreamPlatformService.deleteWmsStreamPlatformByIds(ids));
    }
}
